import Vue from "vue";
import store from "@/store";

const dataAuth = Vue.directive("dataAuth", {
  inserted: function(el, binding, vnode) {
    const dataAuthName = binding.arg || binding.value;
    const dataPermissions = store.getters.dataPermissions;
    if (!dataPermissions.includes(dataAuthName)) {
      (el.parentNode && el.parentNode.removeChild(el)) ||
        (el.style.display = "none");
    }
  },
});

export default dataAuth;
